var actionNodeID="";

jQuery(document).ready(function() {
	//
	$("#layout1").ligerLayout({ leftWidth: 200,height: '100%',heightDiff:-10,space:4});
	
	
	//创建JQGRID表格
	// var grid = 
	$("#table1").ligerGrid({
        columns: [
                  { display: 'id', name: 'id', hide:1, width:1 },
                  { display: '报价单编号', name: 'no', width: 150 },
                  { display: '客户编号', name: 'cliNo', width: 150},
                  { display: '客户名称', name: 'cliName', width: 200},
                  { display: '客户联系人', name: 'cliPeo', width: 100},
                  { display: '报价有效期', name: 'quoteExp', width: 100,
            		  render: function (item){
            			  if(undefined != item.dctime && ''!=item.dctime){
            				  var cdate=new Date(item.dctime);
                			  return formatDate(cdate,"yyyy-MM-dd");
            			  }
            		  }
                  },
                  { display: '单据状态', name: 'billstatus', width: 80,
                	  render: function (item){               		 
                		  var billStatus=item.billstatus;
                		  if(billStatus=="0"){
                			  return "草稿";
                		  }
//                		  if(billStatus=="1"){
//                			  return "提交中";
//                		  }
                		  if(billStatus=="2"){
                			  return "待二级审核";
                		  }
                		  if(billStatus=="3"){
                			  return "待三级审核";
                		  }
                		  if(billStatus=="4"){
                			  return "二审完结";
                		  }
                		  if(billStatus=="5"){
                			  return "三审完结";
                		  }
                		  if(billStatus=="6"){
                			  return "二级已驳回";
                		  }
                		  if(billStatus=="7"){
                			  return "三级已驳回";
                		  }
                		  
                	  }},
                	  { display: '制单人', name: 'listerName', width: 100 },
                	  { display: 'dcruser', name: 'dcruser', width: 1,hide:true },
                	  { display: '创建时间', name: 'dctime', width: 100,
                		  render: function (item){
                			  if(undefined != item.dctime && ''!=item.dctime){
                				  var cdate=new Date(item.dctime);
                    			  return formatDate(cdate,"yyyy-MM-dd");
                			  }
                	  }}
                      ], 
                      usePager: true,pageSize:15,pageSizeOptions :[10,15,20,30,40,50],
                      url : basic_Url+"/list.do",
                      enabledSort:false,//hxm
                      width: "100%", height:"98%", checkbox: true, rownumbers:true,     
                      onDblClickRow : function (data, rowindex, rowobj){
                    	  basic_Title='编辑';
                    	  edit(data);
                      },
                      toolbar: { items: [
										  { text: '增加报价单', click: addtype, icon: 'add' },
										  //{ line: true },
										  //{ text: '修改', click: getSelected, icon: 'modify' },
                                          { line: true },
                                          { text: '删除', click: delitem, img: '../../../js/ligerUI/skins/icons/delete.gif' }
                                         ]
                      }
                  });
	
	//左侧树
	var _tmpParam = {_search:'true',filters:'{"groupOp":"AND","rules":[{"field":"parentname","op":"eq","data":"客户"}]}',sortname:'name',sortorder:''};
	var lefttree1 = $("#tree1").ligerTree({  
		 //url: basic_Url+'/tree.do',
		 nodeWidth: 115,
//		 idFieldName :'code',
		 textFieldName:"name",
		 checkbox: false,
         slide: false,
         onClick:function(node){
        	 actionNodeID = node.data.code;
        	 multipleSearch("#table1",true,"",basic_Url+"/list.do?cli_no="+actionNodeID);
         }
    });
	lefttree1.loadData(null, basic_Url+'/tree.do', _tmpParam ) ;
	
	
	
	$("#pageloading").hide();
});

//添加报价单
function addtype(){
	 	if(actionNodeID == null || actionNodeID.length<=0){
		$.dialog.alert("请选择客户");
		return false;
	}
	var url = basic_WUrl+"/operate/add/0.do?cliNo="+actionNodeID;
	ShowIframeDialog("operate",basic_Title,url,show_Width,show_Hight);
}

////修改物料
//function getSelected(){
//	 var grid = $("#table1").ligerGetGridManager(); 
//		var rows = grid.getCheckedRows();
//		var data =grid.getSelectedRow();
//		if(rows.length!=1){
//			$.dialog.alert("请选择一行数据!");
//			return false;
//		}else{
//			basic_Title='编辑';
//      	  edit(data);
//		}
//}

